/** 坐席工具栏设置 */
import { t } from 'i18next';
import i18next from '../utils/i18next/i18n';

const tools = [
	{
		id: 1,
		icon: '#icon-widget-jieshu',
		text: 'jieshu',
		type: 'end-session'
	},
	{
		id: 3,
		icon: '#icon-widget-pingmugongxiang',
		text: 'pingmugongxiang',
		type: 'screen-share'
	},
	{
		id: 4,
		icon: '#icon-widget-biaozhu',
		text: 'biaozhu',
		type: 'screen-mark'
	},
	{
		id: 5,
		icon: '#icon-widget-zhuanjie',
		text: 'zhuanjie',
		type: 'transfer'
	},
	{
		id: 6,
		icon: '#icon-widget-sanfang',
		text: 'sanfang',
		type: 'invite'
	},
	{
		id: 7,
		icon: '#icon-widget-tongpingfuzhu-hui',
		activeIcon: '#icon-widget-tongpingfuzhu',
		startIcon: '#icon-widget-shouqitongping',
		text: 'tongpingfuzhu-hui',
		activeText: 'tongpingfuzhu',
		type: 'start-screen-sync'
	},
	{
		id: 8,
		icon: '#icon-widget-huoquweizhi',
		text: 'huoquweizhi',
		type: 'get-geo-localtion'
	},
	{
		id: 9,
		icon: '#icon-widget-renzhengduibi',
		text: 'renzhengduibi',
		type: 'idcard-compare'
	},
	{
		id: 10,
		icon: '#icon-widget-luping',
		activeIcon: '#icon-widget-tingzhiluping',
		text: 'luping',
		activeText: 'tingzhiluping',
		type: 'record-screen'
	},
	{
		id: 11,
		icon: '#icon-widget-renlianduibi',
		text: 'renlianduibi',
		type: 'face-compare'
	},
	{
		id: 12,
		icon: '#icon-widget-jieping',
		text: 'jieping',
		type: 'snapshot'
	},
	{
		id: 13,
		icon: '#icon-widget-jietu',
		text: 'jietu',
		type: 'screen-shot'
	},
	{
		id: 14,
		icon: '#icon-widget-saoma',
		text: 'saoma',
		type: 'scanner-code'
	},
	{
		id: 15,
		icon: '#icon-widget-tuisonglianjie',
		text: 'tuisonglianjie',
		type: 'send-link'
	},
	{
		id: 16,
		icon: '#icon-widget-tuisongshipin',
		text: 'tuisongshipin',
		type: 'send-video'
	},
	{
		id: 17,
		icon: '#icon-widget-tuisongbiaodan',
		text: 'tuisongbiaodan',
		type: 'send-form'
	},
	{
		id: 18,
		icon: '#icon-widget-tuisongqianming',
		text: 'tuisongqianming',
		type: 'send-sign'
	},
	{
		id: 19,
		icon: '#icon-widget-tuisongPDF',
		text: 'tuisongPDF',
		type: 'send-pdf'
	},
	{
		id: 20,
		icon: '#icon-widget-kazhengshouji',
		text: 'kazhengshouji',
		type: 'send-card-collection'
	},
	{
		id: 21,
		icon: '#icon-widget-baiban',
		activeIcon: '#icon-widget-zhankaibaiban',
		text: 'baiban',
		activeText: 'zhankaibaiban',
		type: 'shared-whiteboard'
	},
	{
		id: 22,
		icon: '#icon-widget-gongxiangpdf',
		activeIcon: '#icon-widget-zhankaipdf',
		text: 'gongxiangpdf',
		activeText: 'zhankaipdf',
		type: 'shared-pdf'
	},
	{
		id: 23,
		icon: '#icon-widget-bianliangshouji',
		text: 'bianliangshouji',
		type: 'send-variable-collection'
	},
	{
		id: 24,
		icon: '#icon-widget-zhengyanchaolu',
		text: 'zhengyanchaolu',
		type: 'transcript-of-testimony'
	},
	{
		id: 25,
		icon: '#icon-widget-duanshipincaiji',
		text: 'duanshipincaiji',
		type: 'send-video-collection'
	},
	// {
	// 	id: 26,
	// 	icon: '#icon-widget-fuzhubobaohui',
	// 	activeIcon: '#icon-widget-ttsfuzhubobao',
	// 	startIcon: '#icon-widget-shouqifuzhubobao',
	// 	text: 'fuzhubobaohui',
	// 	activeText: 'ttsfuzhubobao',
	// 	type: 'tts-broadcast'
	// },
	{
		id: 27,
		icon: '#icon-widget-quyuluping',
		activeIcon: '#icon-widget-tingzhiquyuluping',
		disableIcon: '#icon-widget-quyulupinbukedianji',
		text: 'quyuluping',
		activeText: 'tingzhiquyuluping',
		type: 'regional-screen-recording'
	},
	{
		id: 28,
		icon: '#icon-widget-zhishiku',
		activeIcon: '#icon-widget-zhishiku',
		disableIcon: '#icon-widget-zhishiku',
		text: 'knowledgebase',
		type: 'knowledge-base'
	},
	{
		id: 29,
		icon: '#icon-widget-shishibiaozhu',
		activeIcon: '#icon-widget-shishibiaozhu',
		disableIcon: '#icon-widget-shishibiaozhu',
		text: 'customer-view-mark',
		type: 'customer-view-mark'
	}
];

const defaultUserEnum = [
	{
		id: 1,
		key: 'userName',
		value: '姓名',
		i18n: 'user-information-name',
		isEdit: false
	},
	{
		id: 2,
		key: 'idCard',
		value: '身份证号',
		i18n: 'user-information-idCard',
		isEdit: false
	},
	{
		id: 3,
		key: 'mobile',
		value: '手机号',
		i18n: 'user-information-mobile',
		isEdit: false
	},
	{
		id: 4,
		key: 'address',
		value: '常住地址',
		i18n: 'user-information-Address',
		isEdit: false
	},
	{
		id: 5,
		key: 'corporate',
		value: '公司名称',
		i18n: 'user-information-corporate-nam',
		isEdit: false
	}
];

// 偏好菜单设置
const defaultUserSettings = [
	{
		id: 1,
		label: '视频画面设置',
		children: [
			{
				label: '添加视频背景、视频水印',
				i18nKey: 'add-virtual-background-watermark', // 添加视频背景、视频水印
				status: ''
			}
		],
		i18nKey: 'virtaul-background-setting', // 视频画面设置
		visible: true
	},

	{
		id: 2,
		label: '视频画面设置',
		children: [
			{
				label: '添加视频背景',
				i18nKey: 'add-virtual-background', // 添加视频背景
				status: ''
			}
		],
		i18nKey: 'virtaul-background-setting', // 视频画面设置
		visible: false
	},
	{
		id: 3,
		label: '系统语言设置',
		children: [
			{
				label: '添加视频背景、视频水印',
				i18nKey: 'zh-ch-tw', // 简体中文、繁体中文
				status: ''
			}
		],
		i18nKey: 'language-setting', // 系统语言设置
		visible: true
	},
	{
		id: 4,
		label: '自动小休设置',
		children: [
			// {
			// 	label: '通话结束后小休',
			// 	i18nKey: 'endSession-otherWork',
			// 	status: 'off'
			// },
			{
				label: '超时未接听后小休',
				i18nKey: 'timeout-otherWork',
				status: 'off'
			}
		],
		i18nKey: 'auto-otherWork', // 自动小休设置
		visible: true
	},
	{
		id: 5,
		label: '开启悬浮框提醒',
		children: [],
		i18nKey: 'open-float-alert', // 开启悬浮框提醒
		visible: true
	}
];

/** 默认偏好设置 */
const defaultPreferenceSettings = {
	deviceConfigHidden: false, // 是否隐藏设备设置(音视频设备+虚拟背景+水印)
	virtualBackgroundConfigHidden: false, // 是否隐藏虚拟背景
	watermarkConfigHidden: false, // 是否隐藏水印
	languageConfigHidden: false, // 是否隐藏多语言
	acceptCallConfigHidden: false, // 是否隐藏接听设置
	floatAlertConfigHidden: false, // 是否隐藏悬浮框提醒
	managementMenuHidden: false, // 是否隐藏管理菜单
	agentManagemenMenuHidden: false, // 是否隐藏座席管理菜单
	userInfoHidden: false, // 是否隐藏用户信息
	chatBoxHidden: false, // 是否隐藏聊天
	layoutConfigHidden: false, // 是否隐藏布局菜单
	bizPannelHidden: false, // 是否隐藏业务操作
	qualityTestingResultHidden: false, // 是否隐藏质检结果
	isImagePreviewHidden: false, // 是否开启图片预览
	isCallProgressHidden: false, // 是否显示排队数
	ignoreTools: [26], // 隐藏工具菜单 ID
	headerMenus: [
		{ label: t('call-service'), i18nKey: 'call-service', key: 'sessionService' },
		{ label: t('service-record'), i18nKey: 'service-record', key: 'serviceRecord' },
		{ label: t('management-service'), i18nKey: 'management-service', key: 'managementService' },
		{ label: t('online-agent-management'), i18nKey: 'online-agent-management', key: 'agentManagement' },
	], // 头部 Tab 标签
	isRecordHidden: false, // 控制显示双录按钮(坐席开启录制/停止录制)
	isNotifyCustomerMediaUpgrade: false, // 是否通知访客媒体升级
	disableAudioAnswerToVideoCall: false // false: 视频进电显示语音和视频按钮，true:视频进电只显示视频按钮
};

/** 设置小休参数 */
export const defaultOtherWorkParams = {
	endSessionOtherWork: 'off',
	timeoutOtherWork: 'off',
	endSessionReason: '话后整理',
	timeoutReason: ''
};

type ITools = 'base' | 'screen-sync';

const getTools = (mode: ITools = 'screen-sync') => {
	return tools;
};

const updateToolsText = (sortTools: any[]) => {
	if (!sortTools) return tools;
	const newTools = sortTools.map((item: any) => {
		const found = tools.find((tool: any) => tool.id == item);
		if (found) {
			return {
				...found
			};
		}
		return item;
	});
	// const clone = JSON.parse(JSON.stringify(sortTools));
	// clone.map((item: any) => {
	// 	tools.forEach(tool => {
	// 		if (item === tool.id) {
	// 			item = tool;
	// 		}
	// 	});
	// 	// item.text = i18next.t(item.icon.replace('#icon-widget-', ''));
	// 	// if (item.activeText && item.activeIcon) {
	// 	// 	item.activeText = i18next.t(item.activeIcon.replace('#icon-widget-', ''));
	// 	// }
	// });
	console.log('sortTools', newTools);
	return newTools;
};

export { tools, getTools, updateToolsText, defaultUserEnum, defaultPreferenceSettings, defaultUserSettings };
